package redis.bloom;

import com.google.common.hash.BloomFilter;
import com.google.common.hash.Funnels;
import redis.clients.jedis.Client;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;

public class BloomTest {

    private String chars;
    {
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i <26 ; i++) {
            builder.append((char)('a'+i));
        }
        chars = builder.toString();
    }

    private String randomString(int n){
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i <n ; i++) {
            int idx = ThreadLocalRandom.current().nextInt(chars.length());
        }
        return builder.toString();
    }

    private List<String> randomUsers(int n){
        List<String> users = new ArrayList<>();
        for (int i = 0; i <1000000 ; i++) {
            users.add(randomString(64));
        }
        return users;
    }

    public static void main(String[] args) {
        BloomTest bloomTest = new BloomTest();
        List<String> users = bloomTest.randomUsers(100000);
        List<String> usersTrain = users.subList(0,users.size()/2);
        List<String> usersTest = users.subList(users.size()/2,users.size());

//        BloomFilter<Integer> file = BloomFilter.create(
//                Funnels.integerFunnel(),
//                5,
//                0.01);


    }


}
